#include <QCoreApplication>
#include "Link.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    //SDK初始化
    Link::init();

    //创建V4L2模块(usb摄像头和采集卡都是这个协议)
    LinkObject *cam=Link::create("InputV4l2");
    QVariantMap dataCam;
    dataCam["path"]="/dev/video0";
    dataCam["format"]="mjpeg";
    dataCam["width"]=1280;
    dataCam["height"]=720;
    cam->start(dataCam);

    //创建mjpeg解码模块
    LinkObject *decV=Link::create("DecodeV");
    decV->start();

    //创建视频输出模块
    LinkObject *vo=Link::create("OutputVo");
    QVariantMap dataVo;
    dataVo["type"]="hdmi";
    vo->start(dataVo);

    /*----如果你的usb摄像头不带麦克风，可以删除下面这部分代码----*/

    //连接视频流(采集->解码->显示)
    cam->linkV(decV)->linkV(vo);

    //创建alsa模块(usb声卡协议)
    LinkObject *alsa=Link::create("InputAlsa");
    QVariantMap dataAlsa;
    dataAlsa["path"]="hw:0,0";
    alsa->start(dataAlsa);

    //创建音频输出模块
    LinkObject *ao=Link::create("OutputAo");
    QVariantMap dataAo;
    //输出到HDMI口，也可以是Line-Out口，具体参见board.json
    dataAo["interface"]="HDMI-OUT";
    ao->start(dataAo);

    //创建音频重采样模块
    LinkObject *res=Link::create("Resample");
    res->start();

    //连接音频流(采集->重采样->输出)
    alsa->linkA(res)->linkA(ao);

    return a.exec();
}

